import turtle
import random
six_six_six=[[340, 300], [340, 200], [340, 100], [340, 0], [340, -100],  [340, -200],  [340, -300]]
colors = ['red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple']

def up_goto(pos):
    """抬起移动到某个位置"""
    turtle.up()
    turtle.goto(pos)
    turtle.down()

def sky():
    turtle.clear()
    # 是否继续运行
    is_run = True
    up_goto([-300, 340])
    turtle.goto([-300, -340])
    for i in range(len(six_six_six)):
        up_goto(six_six_six[i])
        turtle.dot(30, colors[i])
        if six_six_six[i][0]-15 < -300:
            # 当小球边界小于 -300则不再运行
            is_run= False

        six_six_six[i][0] -= random.randint(1, 4) * 10

    if is_run:
        # 如果运行，则定时执行sky
        turtle.ontimer(sky, 250)

turtle.tracer(False)
sky()
turtle.done()


